
#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QGraphicsPixmapItem>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QMediaPlayer>//音乐
#include <QList>//链表
#include <QTimer>//定时器
#include "movedirection.h"
#include <QPushButton>
#include <QToolButton>
#include <QPainter>
#include "text.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget

{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);


    //按键事件
    void keyPressEvent(QKeyEvent* event);
    void keyReleaseEvent(QKeyEvent* event);




    //碰撞函数
    void collision();//碰撞

    //画图
    //virtual void paintEvent(QPaintEvent* event);
    ~Widget();

    //text**********************************************************************************************************************
    void InitByFile(QString fileName);

    void clear();

    //QWidget* widget;

    int length;
    int col;
    int** map;
    int time;
    int TimeLevel;
    int i;

private:
    Ui::Widget *ui;


    //场景视图
    QGraphicsView mGameView;
    QGraphicsScene mScene;
    QGraphicsPixmapItem up;
    QGraphicsPixmapItem left;
    QGraphicsPixmapItem right;
    QGraphicsPixmapItem down;
    QGraphicsPixmapItem up_check;
    QGraphicsPixmapItem left_check;
    QGraphicsPixmapItem right_check;
    QGraphicsPixmapItem down_check;
    QGraphicsPixmapItem background;
    QGraphicsPixmapItem otto;

    //音乐
    QMediaPlayer Music;

    //定时器
    QTimer* DirectPointTimer;//按键变形
    QTimer* DirectMoveTimer;//箭头移动定时器
    QTimer* TimeTimer1;
    QTimer* TimeTimer2;
    QTimer* TimeTimer3;
    QTimer* TimeTimer4;//歌曲时长计时器

    //容器
    QList<int> KeyList;//按键组合
    QList<MoveDirection*>UPsList;
    QList<MoveDirection*>LEFTsList;
    QList<MoveDirection*>DOWNsList;
    QList<MoveDirection*>RIGHTsList;//箭头容器

    //箭头函数
    void DirectChange();//变色

    //谱面
    text* TEXT;

private slots:
    //方向生成函数
    void MakeDirectionUP();
    void MakeDirectionLEFT();
    void MakeDirectionDOWN();
    void MakeDirectionRIGHT();
    void paint0();
    void paint1();
    void paint2();
    void paint3();
    void paint4();

};

#endif // WIDGET_H
